//
//  HMStatusCellBottomView.swift
//  weibo10
//
//  Created by mac on 15/10/21.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit

class HMStatusCellBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    // 懒加载控件
    // 转发按钮
    private lazy var retweetedBtn: UIButton = UIButton(title: " 转发", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_retweet")
    // 评论按钮
    private lazy var commentBtn: UIButton = UIButton(title: " 评论", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_comment")
    // 点赞按钮
    private lazy var unlikeBtn: UIButton = UIButton(title: " 赞", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_unlike")
    
}
// MARK: - 界面设置
extension HMStatusCellBottomView{
    func setupUI(){
        backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        
        // 1.添加控件
        addSubview(retweetedBtn)
        addSubview(commentBtn)
        addSubview(unlikeBtn)
        
        // 2.自动布局
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
            
        }
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedBtn.snp_top)
            make.left.equalTo(retweetedBtn.snp_right)
            make.bottom.equalTo(retweetedBtn.snp_bottom)
            make.width.equalTo(retweetedBtn.snp_width)
        }
        unlikeBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commentBtn.snp_top)
            make.right.equalTo(self.snp_right)
            make.bottom.equalTo(self.snp_bottom)
            make.left.equalTo(commentBtn.snp_right)
            make.width.equalTo(commentBtn.snp_width)
        }
        /// 分割视图
        let sepView1 = sepView()
        let sepView2 = sepView()
        addSubview(sepView1)
        addSubview(sepView2)
        let w = 0.5
        let mul = 0.4
        sepView1.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(self.snp_centerY)
            make.right.equalTo(retweetedBtn.snp_right)
            make.width.equalTo(w)
            make.height.equalTo(retweetedBtn.snp_height).multipliedBy(mul)
        }
        sepView2.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(self.snp_centerY)
            make.right.equalTo(commentBtn.snp_right)
            make.width.equalTo(sepView1.snp_width)
            make.height.equalTo(sepView1.snp_height)
            
        }
        
    }
    private func sepView() -> UIView {
        let sep = UIView()
        sep.backgroundColor = UIColor.grayColor()
        return sep
    }
}